package com.darrenchan.leetcode;

/**
 * @Desc
 * @Author chenchi03
 * @CreateTime 2019-12-28 17:59
 */
public class Q101 {
    public boolean isSymmetric(TreeNode root) {
        if (root == null) {
            return true;
        }

        return help(root.left, root.right);
    }

    private boolean help(TreeNode left, TreeNode right) {
        if (left == null || right == null) {
            return left == right;
        }

        if(left.val != right.val) {
            return false;
        }

        return help(left.left, right.right) && help(left.right, right.left);
    }
}
